const superagent = require('superagent')
const cheerio = require('cheerio')
const express = require('express')
const app = express()



app.get('/', (req, r, next) => {

  superagent.get("https://cnodejs.org/").then(function (res) {
    var items=[]
    let $ = cheerio.load(res.text)
    $('#topic_list .topic_title').each((k, v) => {
      let $a = $(v)
      items.push({
        title: $a.attr('title'),
        href: $a.attr('href')
      })
    })
    r.send(items)
  })

})

app.listen(3000,()=>{
  console.log('服务启动'
  );
})